package cn.yangliu.webflux.service;

import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.transaction.TransactionStatus;

/**
 * @author 杨柳
 * @contact 
 * @date 2019-05-15 23:06
 */
public interface JpaService<T, ID extends Serializable> {

    T execute(Function<TransactionStatus, T> function);

    List<T> findAll();

    List<T> findAll(Sort sort);

    Page<T> findAll(Pageable pageable);

    long count();

    void delete(T entity);

    void deleteAll();

    T save(T entity);

    T saveAndFlush(T entity);

    void deleteInBatch(Iterable<T> entities);

    void deleteAllInBatch();

    T getOne(ID id);

    Iterable<T> findAll(T queryPojo);

    Iterable<T> findAll(T queryPojo, Sort sort);

    Page<T> findAll(T queryPojo, Pageable pageable);

    long count(T queryPojo);

    boolean exists(T queryPojo);

    Optional<T> findById(ID id);

}
